<?php


namespace app\admin\controller;

use liliuwei\think\Auth;
use think\Controller;
use think\facade\Session;
use think\Request;


class common extends Controller
{
   public function initialize()
   {
       if(!Session::has('id')||!Session::has('name')){
           $this->error("您尚未登陆操作系统",url('Login/index'));
       }
       $auth = new Auth();
       //获取当前控制器 和 当前方法名称
       $controller = strtolower(request()->controller());
       $action = strtolower(request()->action());
       $name = $controller.'/'.$action;
       $notCheck = array('index/index','admin/loginout');
       if(Session::get('id')!=9){
           if(!in_array($name,$notCheck)){
               if(!$auth->check($name,session('id'))){
                   $this->error('没有权限',url('index/index'));
               }
           }

       }

   }
}